package com.guit.hrms.mapper;

import com.guit.hrms.dto.MatterDTO;
import com.guit.hrms.po.Matter;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface MatterMapper {
    /**
     * 查询员工个人待办事项
     * @param employeeId 员工id
     * @return 待办事项列表
     */
    @Select("SELECT * FROM matter WHERE employee_id = #{employeeId} ")
    List<Matter> queryMatter(String employeeId);

    /**
     * 添加待办事项
     * @param matterDTO 待办事项信息
     * @return 添加结果
     */
    @Insert("INSERT INTO matter (matter_content, employee_id, start_time, end_time, status) VALUES (#{matterContent}, #{employeeId}, #{startTime}, #{endTime}, 0)")
    Integer addMatter(MatterDTO matterDTO);

    /**
     * 修改待办事项
     * @param matterDTO 待办事项信息
     * @return 修改结果
     */
    Integer updateMatter(MatterDTO matterDTO);

    /**
     * 完成待办事项
     * @param id 待办事项id
     * @return 处理结果
     */
    @Update("UPDATE matter SET status = 1 WHERE id = #{id}")
    Integer finishMatter(Integer id);

    /**
     * 删除员工个人待办事项
     * @param employeeId 员工id
     * @return 删除结果
     */
    @Update("DELETE FROM matter WHERE employee_id = #{employeeId}")
    Integer deleteMatterByEmployeeId(String employeeId);
}
